package org.tacademy.myanimation;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

public class MyButtonAnimationActivity extends Activity {

	Animation flowAnim;
	Animation downAnim;
	TextView text01;
	LinearLayout layout01;
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        flowAnim = AnimationUtils.loadAnimation(this, R.anim.flow);
        downAnim = AnimationUtils.loadAnimation(this, R.anim.flowdown);
        
        text01 = (TextView)findViewById(R.id.textView);
        layout01 = (LinearLayout)findViewById(R.id.layout01);
        
        Button startBtn = (Button)findViewById(R.id.button01);
        
        startBtn.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				text01.startAnimation(flowAnim);
				flowAnim.setAnimationListener(new AnimationListener() {
					
					public void onAnimationStart(Animation animation) {
						
					}
					
					public void onAnimationRepeat(Animation animation) {
						
					}
					
					public void onAnimationEnd(Animation animation) {
						layout01.startAnimation(downAnim);
					}
				});
			}
		});
	
	}
}